package com.vne.skyemart.model;
import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

@Entity
@Table(name = "Products",catalog = "skyemart_db")

public class Products implements Serializable{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 3336399493620797192L;

	@Id
	@GeneratedValue
	@Column(name = "ProductID",nullable = false,length = 20)
	private int productID;

	@Column(name = "Name",nullable = false,length = 30)
	private String name;

	@Column(name = "Price",nullable = false)
	private float price;

	@Column(name = "Description",length = 50)
	private String description;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "CreatedDate",nullable = false)
	private Date createdDate;
	
	@Temporal(TemporalType.DATE)
	@Column(name = "UpdatedDate")
	private Date updatedDate;

	@Temporal(TemporalType.DATE)
	@Column(name = "DeletedDate")
	private Date deletedDate;

	@Column(name = "Status",nullable = false)
	private boolean status;

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "product")
	private Set<Image> image = new HashSet<Image>(0);

	@OneToMany(fetch = FetchType.LAZY,mappedBy = "pk.products")
	private Set<CartItem> cartItem = new HashSet<CartItem>(0);
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "CategoryID",nullable = false)
	private CategoriesProduct categoriesProduct;

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "ManufacturerID",nullable = false)
	private Manufacturer manufacturer;

	/**
	 * CONSTRUCTOR
	 * 
	 */
	public Products() {}
	
	
	public Products(int productID, String name, float price,
			String description, Date createdDate, Date updatedDate,
			Date deletedDate, boolean status, Set<Image> image,
			Set<CartItem> cartItem, CategoriesProduct categoriesProduct,
			Manufacturer manufacturer) {
		this.productID = productID;
		this.name = name;
		this.price = price;
		this.description = description;
		this.createdDate = createdDate;
		this.updatedDate = updatedDate;
		this.deletedDate = deletedDate;
		this.status = status;
		this.image = image;
		this.cartItem = cartItem;
		this.categoriesProduct = categoriesProduct;
		this.manufacturer = manufacturer;
	}


	/**
	 * GETTER AND SETTER
	 * 
	 */
	public int getProductID() {
		return productID;
	}
	public void setProductID(int productID) {
		this.productID = productID;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public float getPrice() {
		return price;
	}
	public void setPrice(float price) {
		this.price = price;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	public Date getCreatedDate() {
		return createdDate;
	}
	public void setCreatedDate(Date createdDate) {
		this.createdDate = createdDate;
	}
	public Date getUpdatedDate() {
		return updatedDate;
	}
	public void setUpdatedDate(Date updatedDate) {
		this.updatedDate = updatedDate;
	}
	public Date getDeletedDate() {
		return deletedDate;
	}
	public void setDeletedDate(Date deletedDate) {
		this.deletedDate = deletedDate;
	}
	public boolean isStatus() {
		return status;
	}
	public void setStatus(boolean status) {
		this.status = status;
	}
	public Set<Image> getImage() {
		return image;
	}
	public void setImage(Set<Image> image) {
		this.image = image;
	}
	public Set<CartItem> getCartItem() {
		return cartItem;
	}
	public void setCartItem(Set<CartItem> cartItem) {
		this.cartItem = cartItem;
	}
	public CategoriesProduct getCategoriesProduct() {
		return categoriesProduct;
	}
	public void setCategoriesProduct(CategoriesProduct categoriesProduct) {
		this.categoriesProduct = categoriesProduct;
	}
	public Manufacturer getManufacturer() {
		return manufacturer;
	}
	public void setManufacturer(Manufacturer manufacturer) {
		this.manufacturer = manufacturer;
	}
	public static long getSerialversionuid() {
		return serialVersionUID;
	}
}
